var findMedianSortedArrays = function(nums1, nums2) {
    var l1 = nums1.length;
    var l2 = nums2.length;
    var i = 0;
    var j = 0;
    var k = 0;
    var result = [];
    var num;
    while(i < l1 && j < l2){
        if (nums1[i] < nums2[j]){
            result[k++] = nums1[i++];
        }else {
            result[k++] = nums2[j++];
        }
    }
    while (i < l1){
        result[k++] = nums1[i++];
    }
    while (j < l2){
        result[k++] = nums2[j++];
    }
    console.log(result.length);
    if (result.length % 2 === 0){
        num = ((result[parseInt(result.length / 2 - 1)] + result[parseInt(result.length / 2)]) / 2).toFixed(1);
    }else {
        num = (result[parseInt((result.length - 1) / 2)]).toFixed(1);
    }
    return num;
};

console.log(findMedianSortedArrays([1, 3], [2]));